if CLIENT then
	include("shared.lua")
	
	SWEP.IconFont = "CSSelectIcons"
	
	SWEP.DrawAmmo			= false
	SWEP.DrawCrosshair		= false
	SWEP.ViewModelFOV		= 75
	SWEP.ViewModelFlip		= false
	SWEP.CSMuzzleFlashes	= false
	
	function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
		draw.SimpleText( "C", self.IconFont, x + wide/2, y + tall*0.2, Color( 200, 20, 15, 255 ), TEXT_ALIGN_CENTER )
	end
end

SWEP.Author = "Rambo_6"
SWEP.HoldType = "slam"

SWEP.ViewModel = "models/Zed/weapons/v_wretch.mdl"
SWEP.WorldModel = ""

SWEP.Primary.Damage = 20
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo	= "none"

SWEP.JumpSound = Sound("npc/fast_zombie/fz_scream1.wav")

function SWEP:GetPrintName()
	return "Zombie"
end

function SWEP:Reload()
	return false
end

function SWEP:Deploy()
	if CLIENT then return end
	self.Owner:DrawWorldModel(false)
	self.Owner:CrosshairDisable()
end

SWEP.NextClimb = 0
function SWEP:SecondaryAttack()
	if CurTime() < self.NextClimb then return end
	self.NextClimb = CurTime() + .2
	local trace = util.GetPlayerTrace(self.Owner)
	local tr = util.TraceLine(trace) 
	if tr.HitPos:Distance(self.Owner:GetShootPos()) < 100 then
		if SERVER then
			self.Owner:SetVelocity(Vector(0,0,250))
		end
		self.Owner:EmitSound(ChooseRandom(GameSounds.Climb),100,math.random(90,110))
	end
end

SWEP.NextSwing = 0
function SWEP:PrimaryAttack()
	if CurTime() < self.NextSwing then return end
	self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
	self.Owner:SetAnimation(PLAYER_ATTACK1)
	self.Owner:EmitSound("npc/fast_zombie/leap1.wav",100,math.random(90,105))
	self.NextSwing = CurTime() + 1
	self.NextHit = CurTime() + 0.3
	self.Owner:Freeze(true)
	local trace = util.GetPlayerTrace(self.Owner)
	local tr = util.TraceLine(trace)
	if tr.HitPos:Distance(self.Owner:GetPos()) < 75 then
		if tr.HitNonWorld then
			self.HitEnt = tr.Entity
		end
	end
end

SWEP.JumpTime = 0
function SWEP:Think()

	if self.Owner:KeyDown( IN_SPEED ) and SERVER then
		if self.JumpTime < CurTime() then
			self.JumpTime = CurTime() + 2.2
			if self.Owner:OnGround() then
				self.Owner:SetVelocity( self.Owner:GetForward() * 550 + Vector(0,0,350) )
				self.Owner:EmitSound(self.JumpSound,100,math.random(95,105))
			end
		end
	end

	if not self.NextHit then return end
	if CurTime() < self.NextHit then return end
	self.NextHit = nil
	self.Owner:Freeze(false)
	
	self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)

	if not self.HitEnt then
		local trace = util.GetPlayerTrace(self.Owner)
		local tr = util.TraceLine(trace)
		if tr.HitPos:Distance(self.Owner:GetShootPos()) < 100 then
			if tr.HitNonWorld then
				self.HitEnt = tr.Entity
			else
				self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
				util.Decal("Blood", tr.HitPos + tr.HitNormal, tr.HitPos - tr.HitNormal)
				return
			end
		end
	end
	if self.HitEnt then
		if self.HitEnt:IsValid() then
			self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
			local phys = self.HitEnt:GetPhysicsObject()
			
			if self.HitEnt:GetModel() == "models/props_debris/wood_chunk03a.mdl" or self.HitEnt:GetModel() == "models/props_debris/wood_chunk03b.mdl" then
				local hit = ChooseRandom(GameSounds.WoodHit)
				self.Owner:EmitSound(hit,100,math.random(90,110))
				self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
				self.HitEnt = nil
				return
			end
			
			if string.find(self.HitEnt:GetClass(),"npc") then
				local vel = self.Owner:EyeAngles():Forward() * 400
				vel.z = 200
				self.HitEnt:SetVelocity(vel)
			end
			
			if self.HitEnt:IsPlayer() then
				if self.HitEnt:Team() == TEAM_UNDEAD then
					local vel = self.Owner:EyeAngles():Forward() * 400
					vel.z = 200
					ent:SetVelocity(vel)
				else
					self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
					if math.random(1,2) == 1 then
						self.HitEnt:DoBleed()
					end
					local effectdata = EffectData()
					effectdata:SetOrigin(self.HitEnt:GetPos() + Vector(0,0,55))
					effectdata:SetNormal(self.Owner:GetAimVector())
					util.Effect("zombie_hit", effectdata, true, true)
				end
			elseif string.find(self.HitEnt:GetClass(),"func_breakable") then
				self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
				self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
			elseif string.find(self.HitEnt:GetClass(),"prop_door") then
				local hit = ChooseRandom(GameSounds.WoodHit)
				if self.HitEnt.HitHealth then
					self.HitEnt.HitHealth = self.HitEnt.HitHealth - 10
					self.Owner:EmitSound(hit,100,math.random(90,110))
					if self.HitEnt.HitHealth <= 0 then
						self.Owner:EmitSound(ChooseRandom(GameSounds.WoodBreak),100,math.random(90,110))
						self.HitEnt:Fire("unlock",1,.1)
						self.HitEnt:Fire("open",1,.1)
						Inventory.RemoveDoor(self.HitEnt)
					end
				else
					self.HitEnt.HitHealth = 20
					self.Owner:EmitSound(hit,100,math.random(90,110))
				end
			elseif phys:IsValid() and string.find(self.HitEnt:GetClass(),"prop_physic") and phys:IsMoveable() then
				local vel = self.Owner:EyeAngles():Forward() * self.Primary.Damage * 800
				if vel.z < 1000 then
					vel.z = 1000 
				end
				phys:ApplyForceCenter(vel)
				self.HitEnt:SetPhysicsAttacker(self.Owner)
				self.HitEnt:TakeDamage(self.Primary.Damage, self.Owner)
				self.Owner:EmitSound(ChooseRandom(GameSounds.Claw),100,math.random(90,110))
			end
		end
 	else
		self.Owner:EmitSound("npc/zombie/claw_miss"..math.random(1, 2)..".wav")
	end
	self.HitEnt = nil
end
